package com.tan.lbs.activity;

import com.tan.lbs.activity.R;
import com.tan.lbs.util.Constants;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import android.widget.Toast;

public class MainPlayTabsHostActivity extends TabActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainplaytabshost);
		
		//Save the global gameID whenever a game is started.
		Intent intent = getIntent();
		String gameIDStr = intent.getStringExtra("gameID");
		if(gameIDStr!=null) {
		SharedPreferences.Editor editor = getSharedPreferences(Constants.PREFS_NAME, 0).edit();
		editor.putString("currentGameID", gameIDStr);
		editor.commit();
		}
 
		TabHost tabHost = getTabHost();
		//Map
		Intent mapIntent = new Intent();
		mapIntent.setClass(this, MapTabActivity.class);
		TabHost.TabSpec mapSpec = tabHost.newTabSpec("GameWorld");
		mapSpec.setIndicator("GameWorld", getResources().getDrawable(R.drawable.map));
		mapSpec.setContent(mapIntent);
		tabHost.addTab(mapSpec);
		
		//Quests
		Intent questIntent = new Intent();
		questIntent.setClass(this, QuestsTabActivity.class);
		TabHost.TabSpec questSpec = tabHost.newTabSpec("Quests");
		questSpec.setIndicator("Quests", getResources().getDrawable(R.drawable.questtab));
		questSpec.setContent(questIntent);
		tabHost.addTab(questSpec);
		
		//Items
		Intent itemIntent = new Intent();
		itemIntent.setClass(this, ItemsTabActivity.class);
		TabHost.TabSpec itemSpec = tabHost.newTabSpec("Inventory");
		itemSpec.setIndicator("Inventory", getResources().getDrawable(R.drawable.inventory));
		itemSpec.setContent(itemIntent);
		tabHost.addTab(itemSpec);
 
		//Info
		Intent infoIntent = new Intent();
		infoIntent.setClass(this, GameInfoTabActivity.class);
		TabHost.TabSpec infoSpec = tabHost.newTabSpec("Info");
		infoSpec.setIndicator("Info", getResources().getDrawable(R.drawable.info));
		infoSpec.setContent(infoIntent);
		tabHost.addTab(infoSpec);
		

		
	}
}
